﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PLC.Domain.Entity;

namespace PLC.Infrastructure.DbContext.Config;

public class DeviceConfigConfig:IEntityTypeConfiguration<DeviceConfig>
{
    public void Configure(EntityTypeBuilder<DeviceConfig> builder)
    {
        builder.ToTable("tb_config_device");
        builder.HasKey(p => p.Id);
        builder.Property(p => p.Id).ValueGeneratedNever();
        builder.HasIndex(p => p.DeviceId);
        builder.Property(p => p.DeviceId).IsRequired();
        builder.Property(p => p.Ip).HasMaxLength(32).IsRequired();
        builder.Property(p => p.Port).IsRequired();
        builder.Property(p => p.MacId).HasMaxLength(32).IsRequired();
        builder.Property(p => p.HardwareType).IsRequired();
        builder.Property(p => p.OrderNum).IsRequired().HasDefaultValue(0);
        builder.Property(p => p.Status).IsRequired();
        builder.Property(p => p.DeviceName).IsRequired().HasMaxLength(128);
    }
}